import 'package:casdon/modules/recipe/data/api/recipe_detail_info_api.dart';
import 'package:casdon/modules/recipe/domain/usecase/recipe_detail_info_usecase.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

class RecipeDetailNotifier extends Notifier<ResponseRecipeDetailApi?> {
  @override
  ResponseRecipeDetailApi? build() {
    return null; // 初始为空
  }

  Future<void> getRecipeDetail(String recipeId) async {
    final result = await ref
        .read(recipeDetailInfoUsecaseProvider)
        .execute(recipeId: recipeId);
    state = result;
  }

  void clear() {
    state = null;
  }
}

// Provider
final recipeDetailProvider =
    NotifierProvider<RecipeDetailNotifier, ResponseRecipeDetailApi?>(
      RecipeDetailNotifier.new,
    );
